<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://lib.baomitu.com/jquery/3.5.1/jquery.min.js"></script>
    <script type="text/javascript">
        // 登录
        function login() {
            var username = document.getElementById("username").value;
            if(!username) {
                alert("请输入用户名");
                return;
            }
            $.post("login",{"username":username},function(data){
                alert(data)
            })
        }
    </script>

</head>
<body>

<form action="/login-get" method="get">
    用户名：<input name="username">
    密码：<input name="password" type="password">
    <input type="submit" value="Get 登录">
</form>

<form action="/login" method="post">
    用户名：<input name="username">
    密码：<input name="password" type="password">
    <input type="submit" value="Post 登录">
</form>

用户名：<input id="username" name="username">
密码：<input id="password" name="password" type="password">
<input type="button" onclick="login()" value="Ajax 登录">
</form>
</body>
</html>